package com.linkage.jz.bankruptcy.activity.Vote;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.fragment.Vote.ProVoteDetailFragment;
import com.linkage.jz.bankruptcy.fragment.Vote.ProVoteGroupInfoFragment;

/**
 * 参会表决 选择我的分组
 */
public class ProVoteMyGroupsActivity extends ProVoteBaseActivity {


    private String voteId;
    private String creditorId;

    private ImageButton titleBack;
    private TextView titleText;

    ProVoteGroupInfoFragment proVoteGroupInfoFragment;

    @Override
    public void initView() {
        setContentView(R.layout.activity_pro_vote_my_group);
    }

    @Override
    public void initTitle() {
        titleBack = findViewById(R.id.title_back);
        titleText = findViewById(R.id.title_text);
        titleBack.setOnClickListener(this);
        titleText.setText("参与表决");
    }

    @Override
    public void initData() {
        voteId = getIntent().getStringExtra("voteId");
        creditorId = getIntent().getStringExtra("creditorId");
        proVoteGroupInfoFragment = ProVoteGroupInfoFragment.newInstance(voteId, creditorId);
        getSupportFragmentManager()    //
                .beginTransaction()
                .add(R.id.fragment_container, proVoteGroupInfoFragment)   // 此处的R.id.fragment_container是要盛放fragment的父容器
                .commit();
    }

    @Override
    public void setListener() {
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == ProVoteEditVoteActivity.REQUEST_CODE_VOTE && resultCode == RESULT_OK && proVoteGroupInfoFragment != null) {
            proVoteGroupInfoFragment.onActivityResult(requestCode, resultCode, data);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.title_back:
                finish();
                break;
        }
    }
}
